# from django.test import TestCase
#
# # Create your tests here.
#
# def fun(a, b, *args, **kwargs):
#     print(a)
#     print(b)
#
#     print(args)
#     print(kwargs)
#
# def f (a, d, *b, **c):
#     print(a)
#     print(d)
#     print(b)
#     print(c)
#
# def fn (a, **c):
#     print(a)
#     print(c)
#
class DisableCSRF(object):
    def process_request(self, request):
        setattr(request, '_dont_enforce_csrf_checks', True)
#
#
# import zipfile
# import os
# def un_zip(path, p):
#     print(os.path.getsize(path))
#     fz = zipfile.ZipFile(path, 'r')
#     for f in fz.namelist():
#         f_new = os.path.join(p, f)
#         data = fz.read(f)
#         file = open(f_new, 'wb')
#         file.write(data)
#         file.close()
#
# import tarfile
# def un_tar(path, p):
#     """
#     path:文件路径
#     p: 目标路径
#     :param path:
#     :param p:
#     :return:
#     """
#     tar = tarfile.open(path)
#     t_name = tar.getnames()
#     for t in t_name:
#         tar.extract(t, p)
#     tar.close()
#
# import rarfile
# def un_rar(path, p):
#     print(os.path.getsize(path))
#     file = rarfile.RarFile(path)
#     file.extractall(p)
#
#
# import uuid
# def un_file(file_path, target_path, file_type):
#     """
#     解压文件
#     :param file_path:
#     :param target_path:
#     :param file_type:
#     :return:
#     """
#     file_name_list = []
#     filedir = {}
#     if file_type == 'zip':
#         fzip = zipfile.ZipFile(file_path, 'r')
#         for fz in fzip.namelist():
#
#             new_name_zip = str(uuid.uuid1()) + '.' + str(fz).split('.')[-1]
#             file_name_list.append(new_name_zip)
#             f_new = os.path.join(target_path, new_name_zip)
#             print('f_new', f_new)
#
#             file = open(f_new, 'wb')
#             file.write(fzip.read(fz))
#             file.close()
#             print(os.path.getsize(f_new))
#             filedir[fz] = os.path.getsize(f_new)
#             # print('pppp')
#         # os.remove(file_path)
#
#
#     if file_type == 'rar':
#         frar = rarfile.RarFile(file_path, 'r')
#         print('h')
#         for fr in frar.namelist():
#             new_name_rar = str(uuid.uuid1()) + '.' + str(fr).split('.')[-1]
#             file_name_list.append(new_name_rar)
#             f_new = os.path.join(target_path, new_name_rar)
#             file = open(f_new, 'wb')
#             file.write(frar.read(fr))
#             file.close()
#             filedir[fr] = os.path.getsize(f_new)
#         os.remove(file_path)
#
#
#     if file_type == 'tar' or file_type == 'gz':
#         tar = tarfile.open(file_path)
#         t_name = tar.getnames()
#         for t in t_name:
#             new_name_tar = str(uuid.uuid1()) + '.' + str(t).split('.')[-1]
#             file_name_list.append(new_name_tar)
#             tar.extract(new_name_tar, target_path)
#         tar.close()
#         # os.remove(file_path)
#
#     return filedir, file_name_list
#
#
#
#
#
# import zipfile
# import os
# import shutil
#
# def extract_all(zip_filename, extract_dir, filename_encoding='GBK'):
#     zf = zipfile.ZipFile(zip_filename, 'r')
#     for file_info in zf.infolist():
#         filename = unicode(file_info.filename, filename_encoding).encode("utf8")
#         print ('filename is ', filename)
#         output_filename = os.path.join(extract_dir, filename)
#         output_file_dir = os.path.dirname(output_filename)
#         if not os.path.exists(output_file_dir):
#             os.makedirs(output_file_dir)
#         with open(output_filename, 'wb') as output_file:
#             shutil.copyfileobj(zf.open(file_info.filename), output_file)
#     zf.close()
#
#
#
# def file_iterator(file_name, chunk_size=512):
# with open(file_name) as f:
#   while True:
#     c = f.read(chunk_size)
#     if c:
#       yield c
#     else:
#       break
# response = StreamingHttpResponse(file_iterator(filename))
# response['Content-Type'] = 'application/octet-stream'
# response['Content-Disposition'] = 'attachment;filename="{0}"'.format(filename)
# return response
#
# if  __name__ == '__main__':
#     # s = '[1, 3, 4]'
#     path = '/root/fpath/ftar.tar'
#     p = '/root/fpath'
#     # extract_all(path, p)
#     # un_zip(path, p)
#     # print(type(path))
#     # print(os.path.split(path)[:-1])
#     # pl = 'fz.ip.zip'
#     # print(pl.split('.')[-1])
#     # f, k = un_file(path, p, 'tar')
#     # print(f)
#     # print(k)
#     # for i in f:
#     #     print(i)
#
#     # print('pp', os.path.getsize('/fileData2/ST/file_manager/drawing/bbe97340-e415-11e7-848b-000c29291d2a.txt'))
#     j = [2, 5, 6]
#     aa = {1: 'a', 2: 'b', 3: 'c'}
#     bb = {9: 'd', 3: 'c', 6: 'b'}
#     yy = {7: 'd', 2: 'c', 8: 'b'}
#     yy.update(aa)
#     print(yy)
#     # # v = dict(aa.items() + bb.items())
#     # g = {}
#     # g.update(aa)
#     # g.update(bb)
#     # g.update(yy)
#     # # print( bb)
#     # # print(g)
#     # # for i in j:
#     # #     k = {i:bb}
#     # #     print(k)
#     # k = {}
#     # k = {1: {2:3}}
#     # print(k)
#     pass
